import { PageHeader } from "@/components/page-header";
import { Button } from "@/components/base";
import { useNavigate } from "react-router-dom";
import * as hooks from '../../hooks';
import * as pages from '@/pages';
import { Controller } from '@/views/basic-layout/controller';
import React from "react";

export function Header() {
    const controller = React.useContext(Controller.Context);
    const navigate = useNavigate();
    const { id } = hooks.useSearch();

    return (
        <PageHeader
            title="客户详情"
            onBack={() => navigate(-1)}
            extra={
                <Button
                    size='small'
                    fill='none'
                    color='primary'
                    onClick={() => {
                        controller.removeTab(pages.customerDetailForm.name);
                        navigate(`/${pages.customerDetailForm.name}?id=${id}`);
                    }}
                >
                    <span>编辑</span>
                </Button>
            }
        />
    );
}
